-
Notifications
You must be signed in to change notification settings - Fork 128
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Replace redundant explicit move-ctors&move-op= by default #10
Closed
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
|
Yup. viktor@pc:~/d/t/build|master✓
➤ git show | grep default
Replace redundant explicit move-ctors&move-op= by default
+ Cell(Cell&&) = default;
+ Cell& operator=(Cell&&) = default;
+ MPMCBoundedQueue(MPMCBoundedQueue&&) = default;
+ MPMCBoundedQueue& operator=(MPMCBoundedQueue&&) = default;
+ ThreadPool(ThreadPool&&) = default;
+ ThreadPool& operator=(ThreadPool&&) = default;
+ Worker(Worker&&) = default;
+ Worker& operator=(Worker&&) = default;
viktor@pc:~/d/t/build|master✓
➤ make clean ; make
Scanning dependencies of target HEADER_ONLY_TARGET
[ 12%] Linking CXX static library libHEADER_ONLY_TARGET.a
[ 12%] Built target HEADER_ONLY_TARGET
[ 25%] Building CXX object tests/CMakeFiles/fixed_function_test.dir/fixed_function.t.cpp.o
[ 37%] Linking CXX executable fixed_function_test
*** Testing FixedFunction ***
- for type size 8
function size is 24
overhead is 200%
- for type size 16
function size is 32
overhead is 100%
- for type size 32
function size is 48
overhead is 50%
- for type size 64
function size is 80
overhead is 25%
- for type size 128
function size is 144
overhead is 12.5%
- test ( alloc/dealloc => succeed )
- test ( free func => succeed )
- test ( free func template => succeed )
- test ( void func => succeed )
- test ( class method void => succeed )
- test ( class method 1 => succeed )
- test ( class method 2 => succeed )
- test ( lambda => succeed )
[ 37%] Built target fixed_function_test
[ 50%] Building CXX object tests/CMakeFiles/thread_pool_test.dir/thread_pool.t.cpp.o
[ 62%] Building CXX object tests/CMakeFiles/thread_pool_test.dir/thread_pool2.t.cpp.o
[ 75%] Linking CXX executable thread_pool_test
*** Testing TP ***
- test ( post job => succeed )
[ 75%] Built target thread_pool_test
[ 87%] Building CXX object benchmark/CMakeFiles/benchmark.dir/benchmark.cpp.o
[100%] Linking CXX executable benchmark
[100%] Built target benchmark
viktor@pc:~/d/t/build|master✓
➤ ./tests/fixed_function_test
*** Testing FixedFunction ***
- for type size 8
function size is 24
overhead is 200%
- for type size 16
function size is 32
overhead is 100%
- for type size 32
function size is 48
overhead is 50%
- for type size 64
function size is 80
overhead is 25%
- for type size 128
function size is 144
overhead is 12.5%
- test ( alloc/dealloc => succeed )
- test ( free func => succeed )
- test ( free func template => succeed )
- test ( void func => succeed )
- test ( class method void => succeed )
- test ( class method 1 => succeed )
- test ( class method 2 => succeed )
- test ( lambda => succeed )
viktor@pc:~/d/t/build|master✓
➤ ./tests/thread_pool_test
*** Testing TP ***
- test ( post job => succeed )
viktor@pc:~/d/t/build|master✓
➤ ./benchmark/benchmark
Benchmark job reposting
***thread pool cpp***
reposted 1000001 in 326.825 ms
reposted 1000001 in 326.917 ms
reposted 1000001 in 326.93 ms
reposted 1000001 in 326.941 ms
reposted 1000001 in 327.907 ms
reposted 1000001 in 328.6 ms
reposted 1000001 in reposted 1000001 in 328.945 ms
328.943 ms
reposted 1000001 in 329.994 ms
reposted 1000001 in 330.661 ms
reposted 1000001 in 330.985 ms
reposted 1000001 in 330.991 ms
reposted 1000001 in 331.382 ms
reposted 1000001 in 331.648 ms
reposted 1000001 in 331.799 ms
reposted 1000001 in 331.814 ms
***asio thread pool***
reposted 1000001 in 7704.77 ms
reposted 1000001 in 7707.09 ms
reposted 1000001 in 7710.09 ms
reposted 1000001 in 7713.3 ms
reposted 1000001 in 7714.2 ms
reposted 1000001 in 7714.54 ms
reposted 1000001 in 7719.97 ms
reposted 1000001 in 7722.57 ms
reposted 1000001 in 7723.58 ms
reposted 1000001 in 7727.21 ms
reposted 1000001 in 7727.41 ms
reposted 1000001 in 7727.56 ms
reposted 1000001 in 7728.78 ms
reposted 1000001 in 7729.22 ms
reposted 1000001 in 7729.29 ms
reposted 1000001 in 7731.99 ms
|
It's true that all the current tests pass, but the truth is that move is not being tested. Apologies for that. As an example, the following test produces a compilation error with your changes: doTest("ctor0", []
{
ThreadPoolStd pool;
auto pool2 = std::move(pool);
}); |
As per above |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Why not just allow compiler do its job?